package com.gitee.zhanyao.test.springrestdoc.controller;

import com.gitee.zhanyao.test.springrestdoc.model.Order;
import com.gitee.zhanyao.test.springrestdoc.model.Pet;
import com.gitee.zhanyao.test.springrestdoc.model.Responses;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;

@Controller
@RequestMapping(value = {"/api/store"}, produces = {"application/json"})
public class PetStoreResource {

    @RequestMapping(value = {"/order/{orderId}"}, method = {RequestMethod.GET})
    public ResponseEntity<Order> getOrderById(@PathVariable("orderId") String orderId) throws NotFoundException {
        Order order = new Order();
        if (null != order) {
            return Responses.ok(order);
        }
        throw new NotFoundException(404, "Order not found");
    }


    @RequestMapping(value = {"/order"}, method = {RequestMethod.POST})
    public ResponseEntity<String> placeOrder(Order order) {
        return Responses.ok("");
    }


    @RequestMapping(value = {"/order/{orderId}"}, method = {RequestMethod.DELETE})
    public ResponseEntity<String> deleteOrder(@PathVariable("orderId") String orderId) {
        return Responses.ok("");
    }


    @RequestMapping(value = {"search"}, method = {RequestMethod.GET}, produces = {"application/json"}, params = {"x=TX"})
    @ResponseStatus(HttpStatus.OK)
    public ResponseEntity<Pet> getPetInTx() {
        throw new UnsupportedOperationException();
    }

    @RequestMapping(value = {"search"}, method = {RequestMethod.GET}, produces = {"application/json"}, params = {"x=CA"})
    @ResponseStatus(HttpStatus.OK)
    public ResponseEntity<Pet> getPetInCA() {
        throw new UnsupportedOperationException();
    }
}